/**   
* @Title: FootballHemaiGetDetailCommunicater.java 
* @Package com.esun.rabbit2.communicaters 
* @Description: (通讯接口,业务标号10042) 
* @author: Kuroky Chengxt@500wan.com   
* @date: 2011-8-17 下午02:27:38  
* Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
*/
package com.esun.rabbit2.communicaters.sportterybasketball;

import java.util.ArrayList;
import java.util.HashMap;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.model.sportterybasketball.BasketballHemaiDetailInfo;
import com.esun.network.ServerCommunicater;

/** 
 * @ClassName: FootballHemaiGetDetailCommunicater 
 * @Description: (获取竞彩篮球合买详细内容) 
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2011-8-17 下午02:27:38 
 *  
 */
public class BasketballHemaiGetDetailCommunicater extends ServerCommunicater {
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;


	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}
	public boolean isGetDetailSucced(String lotId,String programId){
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_HEMAI_DETIAL_BASKETBALL));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotId));
		list.add(mapItem(Key.KEY_PID, programId));
		try {
			// 写入服务器返回信息
			super.getServerResponse(list, true);
			setMsgServer(super.getErrorMSG());
			if (super.getState() == 100) {
				isSucceed = true;				
			} else {
				isSucceed = false;
			}
		} catch (Exception e) {
			isSucceed = false;
			setMsgServer(Language.STR_CONNECTIONFAIL);
		}
		return isSucceed;
	}
	private static final String ALL_MONEY = "allmoney";
	private static final String BEISHU = "beishu";
	private static final String ALL_COUNT = "anumber";
	private static final String EACH_MONEY = "onemoney";
	private static final String BAODI_MONEY = "baodimoney";
	private static final String TICHENG = "bonusratio";
	private static final String STATE = "ismanyuan";
	private static final String JINDU = "renqi";
	private static final String GGTYPE = "ggtype";
	private static final String GGTYPENAME = "ggtypename";
	private static final String HIT_COUNT = "lotterycount";
	private static final String HIT_MONEY = "lotterymonery";
	private static final String LEFT_COUNT = "leftnumber";
	private static final String ADD_TIME = "addtime";
	private static final String ISSUC = "issuc";
	
	private static final String MATCHDATE = "matchnum";
	private static final String HOMESXNAME = "homesxname";
	private static final String AWAYSXNAME = "awaysxname";
	//private static final String RANGQIU = "rangqiu";
	private static final String SPF = "spf";
	private static final String PEILV = "peilv";
	private static final String ISDANMA = "isdanma";
	
	public void updateHemaiDetailInfo(){
		// 比赛数目
		int gameCount = super.getListResult().size();
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setAddTime(super.getResult().get(ADD_TIME));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setAllCount(super.getResult().get(ALL_COUNT));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setAllMoney(super.getResult().get(ALL_MONEY));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setBaodiMoney(super.getResult().get(BAODI_MONEY));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setBeishu(super.getResult().get(BEISHU));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setEachMoney(super.getResult().get(EACH_MONEY));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setHitCount(super.getResult().get(HIT_COUNT));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setHitMoney(super.getResult().get(HIT_MONEY));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setJindu(super.getResult().get(JINDU));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setLeftCount(super.getResult().get(LEFT_COUNT));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setGgtype(super.getResult().get(GGTYPE));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setGgtypeName(super.getResult().get(GGTYPENAME));
		if(super.getResult().get(STATE).equals(Config.NUM1)){
			BasketballHemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_MANYUAN);
		}else{
			BasketballHemaiDetailInfo.getHemaiDetailInfo().setState(Language.POPLOTTERYTIP_WEIMANYUAN);
		}
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setStrFaqiren(super.getResult().get(Key.KEY_USERNAME));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setTicheng(super.getResult().get(TICHENG));
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setIssuc(super.getResult().get(ISSUC));
		
		String[] matchdate = new String[gameCount];
		String[] homesxname = new String[gameCount];
		String[] awaysxname = new String[gameCount];
		//String[] rangqiu = new String[gameCount];
		String[] spf = new String[gameCount];
		String[] peilv = new String[gameCount];
		String[] isdanma = new String[gameCount];
		for (int i = 0; i < gameCount; i++) {
			matchdate[i] = super.getListResult().get(i).get(MATCHDATE);
			homesxname[i] = super.getListResult().get(i).get(HOMESXNAME);
			awaysxname[i] = super.getListResult().get(i).get(AWAYSXNAME);
			//rangqiu[i] = super.getListResult().get(i).get(RANGQIU);
			spf[i] = super.getListResult().get(i).get(SPF);
			peilv[i] = super.getListResult().get(i).get(PEILV);
			isdanma[i] = super.getListResult().get(i).get(ISDANMA);
		}
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setMatchdate(matchdate);
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setHomesxname(homesxname);
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setAwaysxname(awaysxname);
		//BasketballHemaiDetailInfo.getHemaiDetailInfo().setRangqiu(rangqiu);
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setSpf(spf);
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setPeilv(peilv);
		BasketballHemaiDetailInfo.getHemaiDetailInfo().setIsdanma(isdanma);
	}
	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
